﻿/*
原作者：	王成友			
原作日期：	[2010-5-27]
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;


namespace Nova_Common
{
    public class MessageBox
    {
        #region 警告函数
        ///<summary>
        /// 写警告,仅弹出对话框
        ///</summary>
        public static void ShowMessageBox(string text)//弹出对话框
        {
            HttpContext.Current.Response.Write("<Script language=javascript>alert('" + text + "');</script>");
        }
        ///<summary>
        /// 写警告,仅弹出对话框关闭窗口
        ///</summary>
        public static void MessageBoxClose(string text)//弹出对话框
        {
            HttpContext.Current.Response.Write("<Script language=javascript>");
            HttpContext.Current.Response.Write("alert('" + text + "');");
            HttpContext.Current.Response.Write("window.close()");
            HttpContext.Current.Response.Write("</script>");
        }

        ///<summary>
        /// 写警告,返回原来页面
        ///</summary>
        public static void MessageBoxBack(string text)//返回原来页面
        {
            HttpContext.Current.Response.Write("<Script language=javascript>");
            HttpContext.Current.Response.Write("alert('" + text + "');");
            HttpContext.Current.Response.Write("window.history.go(-1)");
            HttpContext.Current.Response.Write("</script>");
        }
        ///<summary>
        /// 页面转向
        /// text 警告文本,转向页面,转向目标
        ///</summary>
        public static void MessageBoxRedirect(string text, string gourl, string target)
        {
            if (target == "" || target == null)
            { target = "window"; }
            HttpContext.Current.Response.Write("<Script language=javascript>");
            HttpContext.Current.Response.Write("alert('" + text + "');");
            HttpContext.Current.Response.Write("window." + target + ".location='" + gourl + "';");
            HttpContext.Current.Response.Write("</script>");
        }
        ///<summary>
        /// 页面转向
        /// text 警告文本,转向页面
        ///</summary>
        public static void MessageBoxRedirect(string text, string gourl)
        {
            HttpContext.Current.Response.Write("<Script language=javascript>");
            HttpContext.Current.Response.Write("alert('" + text + "');");
            HttpContext.Current.Response.Write("window.location='" + gourl + "';");
            HttpContext.Current.Response.Write("</script>");
        }
        #endregion
    }
}
